<template>
	<view class="tj">
		<!-- 1 -->
		<view class="user_box" v-for="item in user" :key="item.id">
			<view class="user_info">
				<view class="avatar">
					<image :src="item.headimgurl" mode=""></image>
				</view>
				<view class="user_name">
					<view class="name">
						{{ item.realname ? item.realname : item.wnickname }}
					</view>
					<view class="phone">
						{{ item.phone }}
					</view>
				</view>
				
			</view>
			<view class="role">
				<van-tag type="primary">
					{{ item.role_id | roleMat }}
				</van-tag>
			</view>
			<view class="status">
				关联中
			</view>
		</view>
		<!-- 2 -->
		<view class="none" v-if="user.length == 0">
			暂无推荐人
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				user: [],
			}
		},
		computed: {
			token() {
				return this.$store.state.token;
			}
		},
		filters: {
			roleMat(val) {
				if(val == 3) {
					return "普通会员"
				} else if (val == 4) {
					return "技工"
				} else if (val == 5) {
					return "商家"
				} else if (val == 5) {
					return "创客"
				} 
			},
		},
		onLoad() {
			
		},
		onShow() {
			this.getUser()
		},
		methods: {
			// 获取我的推荐人
			async getUser() {
				let res = await this.$Request("POST", "/mydata/myuser", { token: this.token })
				 console.log(res);
				if(res.data.code == 200 || res.data.code == 202) {
					this.user = res.data.data
					
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	.tj {
		width: 100%;
		box-sizing: border-box;
		padding: 20rpx 30rpx;
		.none {
			width: 100%;
			box-sizing: border-box;
			padding: 100rpx 30rpx;
			text-align: center;
			color: #aaa;
		}
		.user_box {
			width: 100%;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			border-radius: 30rpx;
			box-shadow: 0 0 12rpx #007eff;
			padding: 20rpx;
			margin: 20rpx 0;
			.user_info {
				flex:1;
				display: flex;
				align-items: center;
				.avatar {
					width: 80rpx;
					height: 80rpx;
					border: 1px solid #999;
					border-radius: 50%;
					overflow: hidden;
					image {
						width: 80rpx;
						height: 80rpx;
						border-radius: 50%;
					}
				}
				.user_name {
					margin-left: 30rpx;
					font-size: 26rpx;
					.name {
						width: 100%;
						overflow: hidden;
						white-space: nowrap;
						text-overflow: ellipsis;
					}
				}
				
			}
			.role {
				margin-left: 30rpx;
				font-size: 24rpx;
				color: #007AFF;
				width: 150rpx;
			}
			.status {
				width: 100rpx;
				font-size: 24rpx;
				color: #007AFF;
			}
		}
	}
</style>
